home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / boot / Kickstop.lha / Kickstop / AsmStartup / startup.i < prev    next >
Text File  |  1999-01-03  |  21KB  |  639 lines

  1. ********************************************************************************
  2. *
  3. *       Program:        startup
  4. *       Filename:       startup.i
  5. *
  6. *       Contents:       AMIGA startup code (description below)
  7. *
  8. *       Language:       68000 Assembler
  9. *
  10. *       Author:         Johannes R. Geiss
  11. *
  12. *       Copyright:      Amigavisions & Commodore-Amiga, Inc.
  13. *
  14. *       History:        $HISTORY:
  15. *                       1.2 (26-Oct-91) changed JRG
  16. *                       1.1 (15-Oct-91) changed JRG
  17. *                       1.0 (13-Oct-91) written JRG
  18. *
  19. *       Version:        $VER: startup.i 1.2 (26-Oct-91)
  20. *
  21. ********************************************************************************
  22. *
  23. *       Description:
  24. *
  25. * Conditional assembly flags:
  26. *       ASTART: 1=Standard Globals Defined      0=Reentrant Only
  27. *       WINDOW: 1=AppWindow for WB startup      0=No AppWindow code
  28. *       XNIL:   1=Remove startup NIL: init      0=Default Nil: WB Output
  29. *       NARGS:  1=argv[0] only                  0=Normal cmd line arg parse
  30. *       DEBUG:  1=Set up old statics for Wack   0=No extra statics
  31. *       QARG:   1=No argv                       0=Passes argc,argv
  32. *
  33. * Flags for   Astart  AWstart Rstart  RWstart RXstart Qstart  Nstart  Dstart
  34. *  ASTART       1       1       0       0       0       0       1       1
  35. *  WINDOW       0       1       0       1       0       0       0       0
  36. *  XNIL         0       0       0       0       1       1       0       0
  37. *  NARGS        0       0       0       0       0       0       1       0
  38. *  DEBUG        0       0       0       0       0       0       0       1
  39. *  QARG         0       0       0       0       0       1       0       0
  40. *
  41. *  This startup dynamically allocates a structure which includes the argv
  42. * buffers. If you use this startup, your code must return to this startup when
  43. * it exits. Use exit(n) of final curly brace (rts) to return here. Do not use
  44. * AmigaDOS Exit() function. Due this dynamic allocation and some code
  45. * consolidation, this startup can make executables several hundred bytes
  46. * smaller.
  47. *
  48. *  Because a static initialSP variable can not be used, this code depends on
  49. * the fact that AmigaDOS places the address of the top of our stack in SP and
  50. * proc->pr_ReturnAddr right before JSR'ing to us. This code uses
  51. * pr_ReturnAddr when restoring SP.
  52. *
  53. *  Most versions of startup will initialize a Workbench process's input and
  54. * output streams (and stdio globals if present) to NIL: if no other form of
  55. * Workbench output (like WINDOW) is provided. This should help prevent crashes
  56. * if a user puts an icon on a CLI program, and will also protect against care-
  57. * less sdtio debugging or error messages left in a Workbench IO stream only
  58. * be removed by assembling startup with ASTART and WINDOW set to 0, and XNIL
  59. * set to 1.
  60. *
  61. *
  62. * Some startups which can be conditionally assembled:
  63. *
  64. *  1. Standard Astartup for non-reentrant code
  65. *  2. Reentrant Rstartup (no unshareable globals)
  66. *  3. Smaller reentrant-only RXstartup (no NIL: WB init code)
  67. *  4. Standard AWstartup (WB output window) for non-reentrant code
  68. *  5. Reentrant RWstartup (WB output window, no unshareable globals)
  69. *  6. Smallest Qstartup (No argv - argv is ptr to NULL string)
  70. *  7. Standard Nstartup (no arguments, only command name)
  71. *  8. Standard Dstartup (plus initialSP, dosCmdLen and dosCmdBuf)
  72. *
  73. *
  74. * Explanation of conditional assembly flags:
  75. *
  76. *  ASTART (ASTART set 1) startups will set up and xdef the global variables
  77. * _stdin, _stdout, _stderr and _WBenchMsg. These startups can be used
  78. * as smaller replacements for startups like (A)startup.obj and TWstartup.obj.
  79. * Startups with ASTART would generally be used for non-reentrant programs,
  80. * although the startup code ifself is still reentrant if the globals are not
  81. * referenced.
  82. *  Reentrant (ASTART set 0) startups will NOT set up or xdef the sdtio and
  83. * WBenchMsg globals. This not only makes the startup slightly smaller, but also
  84. * lets you know if your code is referencing these non-reentrant globals (you
  85. * will get an unresolved external reference when you link). Programs get their
  86. * input and output handlers from Input() and Output(), and the WBenchMsg is
  87. * passed in argv on Workbench startup.
  88. *
  89. *  WINDOW (WINDOW set 1) startups use an xref'd CON: string named AppWindow,
  90. * defined in your application, to open a stdio console window when your
  91. * application is started from Workbench. For non-reentrant programs, this
  92. * window can be used for normal stdio (printf, getchar, etc). For reentrant
  93. * programs the window is Input() and Output(). WINDOW is useful when adding
  94. * other Workbench capability to a stdio application, and also for debugging
  95. * other Workbench applications. To insure that applications requiring a window
  96. * startup are linked with a window startup, the label _NeedWstartup can be
  97. * externed and referenced in the application so that a linker error will occur
  98. * if linked with a standard startup.
  99. *
  100. *       example:  /* Optional safety reference to NeedWstartup */
  101. *                 extern UBYTE NeedWstartup;
  102. *                 UBYTE *HaveWstartup = &NeedWstartup;
  103. *                 /* Required window specification */
  104. *                 char AppWindow[] = "CON:30/30/200/150/MyProgram";
  105. *                 ( OR char AppWindow[] = "\0"; for no window)
  106. *
  107. *
  108. *  XNIL (XNIL set 1) allows the creation of smaller startup by removing the
  109. * code that initializes a Workbench process's output streams to NIL:. This flag
  110. * can only remove the code if it is not required for ASTART or WINDOW.
  111. *
  112. *  NARGS (NARGS set 1) removes the code used to parse command line arguments.
  113. * The command name is still passed to _main as argv[0]. This option can take
  114. * about 120 bytes off the size of any program that does not use command line
  115. * args.
  116. *
  117. *  DEBUG (DEBUG set 1) will cause the old startup.asm statics initialSP,
  118. * dosCmdLen and dosCmdBuf to be defined and initialized by the startup code,
  119. * for use as debugging symbols when using Wack.
  120. *
  121. *  QARG (QARG set 1) will bypass all argument parsing. A CLI startup is passed
  122. * argc == 1, and a Workbench startup is passed argc == 0. argv[0] will be a
  123. * pointer to the a NULL string rather than a pointer to the command name. This
  124. * option creates a very small startup with no sVar structure allocation, and
  125. * therefore must be used with XNIL (it is incompatible with default or
  126. * AWindow output options).
  127. *
  128. *
  129. * RULES FOR REENTRANT CODE
  130. *
  131. *       - Make no direct of indirect (printf, etc) references to the globals
  132. *         _stdin, _stdout, _stderr, or _WBenchMsg.
  133. *
  134. *       - For stdio use either special versions of printf and getchar that
  135. *         use Input() and Output() rather than _stdin and _stdout, or use
  136. *         fprintf and fgetc with Input() and Output() file handlers.
  137. *
  138. *       - Workbench applications must get the pointer to the WBenchMsg from
  139. *         argv rather than from global extern WBenchMsg.
  140. *
  141. *       - Use no global or static variables within your code. Instead, put
  142. *         all formaer globals in a dynamically allocated structure, and pass
  143. *         around a pointer to that structure. The only acceptable globals
  144. *         are constants (message, strings, etc) and global copies of Library
  145. *         Bases to resolve amiga.lib references. Your code must return all
  146. *         OpenLibrary's into non-global variables, copy the result to the
  147. *         global library base only if successful, and use the non-globals
  148. *         when deciding whether to Close any opened libraries.
  149. *
  150. *
  151. * ADDITIONAL NOTES
  152. *
  153. *       The original startup code printed in AMIGA ROM KERNEL REFERENCE MANUAL:
  154. *       LIBRARY & DEVICES (V1.3) does not work with BLink Version 6.7.
  155. *       Now this code works correctly. Furthermore I did a few improvements
  156. *       for smaller and faster code.
  157. *
  158. *         THIS ASSEMBLY SOURCE AND OBJECT FILE IS FOR PRIVATE USE ONLY!
  159. *
  160. *                                                              Johannes R. Geiss
  161. *
  162. ********************************************************************************
  163. *
  164. * EXAMPLE FOR A SOURCE CODE TO INVOKE THIS FILE:
  165. *
  166. *       *------ Equates
  167. *       ASTART  set     1
  168. *       WINDOW  set     0
  169. *       XNIL    set     0
  170. *       NARGS   set     0
  171. *       DEBUG   set     0
  172. *       QARG    set     0
  173. *
  174. *       *------ Includes
  175. *               include 'startup.i'
  176. *
  177. ********************************************************************************
  178.  
  179.  
  180.         IFND STARTUP_I
  181. STARTUP_I SET 1
  182.  
  183.  
  184. *------ Includes
  185.         include 'exec/types.i'
  186.         include 'exec/alerts.i'
  187.         include 'exec/memory.i'
  188.         include 'libraries/dos.i'
  189.         include 'libraries/dosextens.i'
  190.         include 'workbench/startup.i'
  191.  
  192.  
  193. *------ Macros
  194. XLIB    MACRO
  195.         xref    _LVO\1
  196.         ENDM
  197.  
  198. CALLSYS MACRO
  199.         jsr     _LVO\1(a6)
  200.         ENDM
  201.  
  202. CALLEXE MACRO
  203.         movea.l _SysBase,a6
  204.         jsr     _LVO\1(a6)
  205.         ENDM
  206.  
  207. CALLGFX MACRO
  208.         movea.l _GfxBase,a6
  209.         jsr     _LVO\1(a6)
  210.         ENDM
  211.  
  212. CALLITU MACRO
  213.         movea.l _IntuitionBase,a6
  214.         jsr     _LVO\1(a6)
  215.         ENDM
  216.  
  217. CALLDOS MACRO
  218.         movea.l _DOSBase,a6
  219.         jsr     _LVO\1(a6)
  220.         ENDM
  221.  
  222. LINKSYS MACRO
  223.         move.l  a6,-(a7)
  224.         move.l  \2,a6
  225.         jsr     _LVO\1(a6)
  226.         move.l  (a7)+,a6
  227.         ENDM
  228.  
  229. LINKEXE MACRO
  230.         move.l  a6,-(a7)
  231.         movea.l _SysBase,a6
  232.         jsr     _LVO\1(a6)
  233.         move.l  (a7)+,a6
  234.         ENDM
  235.  
  236. LINKGFX MACRO
  237.         move.l  a6,-(a7)
  238.         movea.l _GfxBase,a6
  239.         jsr     _LVO\1(a6)
  240.         move.l  (a7)+,a6
  241.         ENDM
  242.  
  243. LINKITU MACRO
  244.         move.l  a6,-(a7)
  245.         movea.l _IntuitionBase,a6
  246.         jsr     _LVO\1(a6)
  247.         move.l  (a7)+,a6
  248.         ENDM
  249.  
  250. LINKDOS MACRO
  251.         move.l  a6,-(a7)
  252.         movea.l _DOSBase,a6
  253.         jsr     _LVO\1(a6)
  254.         move.l  (a7)+,a6
  255.         ENDM
  256.  
  257.  
  258. *------ Equates
  259. WBOUT   set     (ASTART!WINDOW!(1-XNIL))
  260.  
  261.         IFEQ    QARG
  262. ARGVSLOTS       equ     32
  263.         STRUCTURE sVar,0
  264.         LONG    sv_WbOutput
  265.         STRUCT  sv_argvArray,ARGVSLOTS*4
  266.         STRUCT  sv_argvBuffer,256
  267.         LABEL   sv_SIZEOF
  268.         ENDC
  269.  
  270.  
  271. *------ Imports
  272.         xref    _main           ; Entry point for C & assembly codes
  273.         xref    _AbsExecBase
  274.  
  275.         IFGT    WINDOW
  276.         xref    _AppWindow      ; CON: spec in application for WB stdio window
  277.         xdef    _NeedWstartup   ; May be externed and referenced in application
  278.         ENDC
  279.  
  280.         XLIB    Alert
  281.         XLIB    AllocMem
  282.         XLIB    FindTask
  283.         XLIB    Forbid
  284.         XLIB    FreeMem
  285.         XLIB    GetMsg
  286.         XLIB    OpenLibrary
  287.         XLIB    CloseLibrary
  288.         XLIB    ReplyMsg
  289.         XLIB    Wait
  290.         XLIB    WaitPort
  291.  
  292.         XLIB    CurrentDir
  293.         XLIB    Open
  294.         XLIB    Close
  295.         XLIB    Input
  296.         XLIB    Output
  297.  
  298.  
  299. *------ Exports
  300.         IFGT    ASTART
  301.         xdef    _stdin
  302.         xdef    _stdout
  303.         xdef    _stderr
  304.         xdef    _WBenchMsg
  305.         ENDC
  306.  
  307.         xdef    _SysBase
  308.         xdef    _DOSBase
  309.         xdef    _exit           ; Exit point for C & assembly codes
  310.  
  311.  
  312. ********************************************************************************
  313.  
  314.  
  315.         SECTION AsmStartup,CODE
  316.  
  317. *------ Standard Program Entry Point
  318. *
  319. * Input: d0.l dosCmdLen
  320. *        a0.l dosCmdBuf
  321.  
  322. startup
  323.         IFGT    DEBUG
  324.         move.l  a7,initialSP
  325.         move.l  d0,dosCmdLen
  326.         move.l  a0,dosCmdBuf
  327.         ENDC
  328.  
  329.         IFEQ    QARG
  330.         move.l  d0,d2
  331.         movea.l a0,a2
  332.         ENDC
  333.  
  334.         movea.l _AbsExecBase,a6 ; get Exec library base pointer
  335.         move.l  a6,_SysBase
  336.  
  337.         suba.l  a1,a1           ; get the address of our task
  338.         CALLSYS FindTask
  339.         movea.l d0,a4           ; keep task in a4
  340.  
  341.         moveq.l #33,d0          ; Get DOS library base pointer (version 33)
  342.         lea     DOSName,a1      ; dos.library
  343.         CALLSYS OpenLibrary
  344.         move.l  d0,_DOSBase     ; set global
  345.         beq     alertDOS        ; fail on null with alert
  346.  
  347.         IFEQ    QARG
  348.         move.l  #sv_SIZEOF,d0   ; alloc the argument structure
  349.         move.l  #(MEMF_PUBLIC!MEMF_CLEAR),d1
  350.         CALLSYS AllocMem
  351.         tst.l   d0
  352.         beq     alertMem        ; fail on null with alert
  353.         move.l  d0,-(a7)        ; save sVar ptr on stack
  354.         movea.l d0,a5           ; sVar ptr to a5
  355.         ENDC
  356.  
  357.         IFGT    QARG
  358.         clr.l   -(a7)
  359.         ENDC
  360.  
  361.         clr.l   -(a7)           ; reserve space for WBenchMsg if any
  362.         move.l  pr_CLI(a4),d0   ; branch to Workbench startup code if not a
  363.         beq     fromWorkbench   ; CLI process
  364.  
  365. *------ CLI startup code
  366.         IFEQ    QARG
  367.         lsl.l   #2,d0           ; find command name
  368.         movea.l d0,a0
  369.         move.l  cli_CommandName(a0),d0
  370.         lsl.l   #2,d0
  371.         lea     sv_argvBuffer(a5),a1    ; start argv array
  372.         lea     sv_argvArray(a5),a3
  373.         movea.l d0,a0           ; copy command name
  374.         moveq.l #0,d0
  375.         move.b  (a0)+,d0
  376.         clr.b   0(a0,d0.l)      ; terminate the command name
  377.         move.l  a0,(a3)+
  378.         moveq.l #1,d3           ; start counting arguments
  379.         IFEQ    NARGS
  380.         lea     0(a2,d2.l),a0   ; null terminate the arguments, eat trailing
  381. strjunk cmpi.b  #$20,-(a0)      ; control characters
  382.         dbhi    d2,strjunk
  383.         clr.b   1(a0)
  384. newarg  move.b  (a2)+,d1        ; start gathering arguments into buffer
  385.         beq.s   paramExit       ; skip spaces
  386.         cmpi.b  #$20,d1
  387.         beq.s   newarg
  388.         cmpi.b  #9,d1           ; tab
  389.         beq.s   newarg
  390.         cmpi.w  #ARGVSLOTS-1,d3 ; check for argument count overflow
  391.         beq.s   paramExit
  392.         move.l  a1,(a3)+        ; push address of the next parameter
  393.         addq.w  #1,d3
  394.         cmpi.b  #34,d1          ; process quotes
  395.         beq.s   doquote
  396.         move.b  d1,(a1)+        ; copy the parameter in
  397. nextchr move.b  (a2)+,d1        ; null termination check
  398.         beq.s   paramExit
  399.         cmpi.b  #$20,d1
  400.         beq.s   endarg
  401.         move.b  d1,(a1)+
  402.         bra.s   nextchr
  403. endarg  clr.b   (a1)+
  404.         bra.s   newarg
  405. doquote move.b  (a2)+,d1        ; process quoted strings
  406.         beq.s   paramExit
  407.         cmpi.b  #34,d1          ; quote
  408.         beq.s   endarg
  409.         cmpi.b  #'*',d1         ; '*' is the BCPL escape character
  410.         bne.s   addquc
  411.         move.b  (a2)+,d1
  412.         move.b  d1,d2
  413.         andi.b  #$df,d2         ; d2 is temp toupper'd d1
  414.         cmpi.b  #'N',d2         ; check for dos newline char
  415.         bne.s   chkEsc
  416.         moveq.l #10,d1          ; got a *N -- turn into a newline
  417.         bra.s   addquc
  418. chkEsc  cmpi.b  #'E',d2
  419.         bne.s   addquc
  420.         moveq.l #27,d1          ; got a *E -- turn into a escape
  421. addquc  move.b  d1,(a1)+
  422.         bra.s   doquote
  423. paramExit
  424.         clr.b   (a1)            ; all done -- null terminate the arguments
  425.         clr.l   (a3)
  426.         ENDC
  427.  
  428.         pea     sv_argvArray(a5)        ; argv
  429.         move.l  d3,-(a7)                ; argc
  430.         ENDC
  431.  
  432.         IFGT    QARG
  433.         pea     nullArgV        ; pointer to pointer to null string
  434.         pea     1               ; only one pointer
  435.         ENDC
  436.  
  437.         IFGT    ASTART
  438.         movea.l _DOSBase,a6
  439.         CALLSYS Input           ; get standard input handle
  440.         move.l  d0,_stdin
  441.         CALLSYS Output          ; get standard output handle
  442.         move.l  d0,_stdout
  443.         move.l  d0,_stderr
  444.         movea.l _SysBase,a6
  445.         ENDC
  446.  
  447.         bra.s   domain          ; Ok, let's go...
  448.  
  449. *------ Workbench startup code
  450. fromWorkbench
  451.         bsr.s   getWbMsg        ; get the startup message that workbench will
  452.         move.l  d0,(a7)         ; send to us. Must get this message before
  453.                                 ; doing any DOS calls. Save this message for
  454.         IFGT    ASTART          ; later
  455.         move.l  d0,_WBenchMsg
  456.         ENDC
  457.  
  458.         move.l  d0,-(a7)        ; push the message on the stack for wbmain
  459.         clr.l   -(a7)           ; (as argv). Indicate run from WB (argc=0)
  460.  
  461.         IFNE    (1-QARG)+WBOUT
  462.         movea.l _DOSBase,a6     ; put DOSBase in a6 for next few calls
  463.         ENDC
  464.  
  465.         IFEQ    QARG
  466.         movea.l d0,a2           ; get the first argument
  467.         move.l  sm_ArgList(a2),d0
  468.         beq.s   doCons
  469.         movea.l d0,a0           ; and set the current directory to the same dir
  470.         move.l  wa_Lock(a0),d1
  471.         beq.s   doCons
  472.         CALLSYS CurrentDir
  473. doCons  
  474.         ENDC
  475.  
  476.         IFGT    WBOUT           ; Open NIL: or AppWindow for WB Input()/Output()
  477.                                 ; handle. Also for possible initialization of
  478.         IFGT    WINDOW          ; stdio globals. stdio used to be init to -1
  479.         lea     _AppWindow,a0   ; Get AppWindow defined in application
  480.         tst.b   (a0)
  481.         bne.s   doOpen          ; Open if not null string
  482.         ENDC
  483.  
  484.         lea     NilName,a0      ; Open NIL: if no window provided
  485. doOpen  move.l  a0,d1           ; Open up the file whose name is in a0
  486.         move.l  #MODE_OLDFILE,d2
  487.         CALLSYS Open
  488.         move.l  d0,sv_WbOutput(a5)      ; d0 now contains handle for WB Output
  489.         bne.s   gotOpen
  490.         moveq.l #RETURN_FAIL,d2
  491.         bra     exit2
  492. gotOpen
  493.  
  494.         IFGT    ASTART
  495.         move.l  d0,_stdin       ; set the C input and output descriptors
  496.         move.l  d0,_stdout
  497.         move.l  d0,_stderr
  498.         ENDC
  499.  
  500.         move.l  d0,pr_CIS(a4)   ; set the console task (so Open("*",mode)
  501.         move.l  d0,pr_COS(a4)   ; will work (task pointer still in a4
  502.         lsl.l   #2,d0
  503.         movea.l d0,a0
  504.         move.l  fh_Type(a0),d0
  505.         beq.s   noConTask
  506.         move.l  d0,pr_ConsoleTask(a4)
  507. noConTask
  508.         ENDC
  509.  
  510. *------ CLI $ Workbench startup code (continued)
  511. *
  512. * Calls
  513. *       main(argc,argv)
  514. *            int   argc;
  515. *            char *argv[];
  516. *
  517. * For Workbench startup, argc=0, argv=WBenchMsg
  518.  
  519. domain  bsr     _main           ; main didn't use exit(n) so provide success
  520.         moveq.l #RETURN_OK,d2   ; return code
  521.         bra.s   exit2
  522.  
  523.  
  524. ********************************************************************************
  525.  
  526.  
  527. *------ get Workbench message
  528. getWbMsg
  529.         lea     pr_MsgPort(a4),a0       ; our process base
  530.         CALLSYS WaitPort                ; a6=ExecBase
  531.         lea     pr_MsgPort(a4),a0
  532.         CALLSYS GetMsg
  533.         rts
  534.  
  535.  
  536. *------ Alert
  537. alertDOS
  538.         ALERT   (AG_OpenLib!AO_DOSLib)  ; no dos library
  539.  
  540.         IFEQ    QARG
  541.         bra.s   failExit
  542. alertMem
  543.         movea.l _DOSBase,a1             ; Close DOS
  544.         CALLSYS CloseLibrary
  545.         ALERT   AG_NoMemory             ; no memory
  546.         ENDC
  547.  
  548. failExit
  549.         tst.l   pr_CLI(a4)
  550.         bne.s   fail2
  551.         bsr.s   getWbMsg
  552.         movea.l d0,a2
  553.         bsr.s   repWbMsg
  554. fail2   moveq.l #RETURN_FAIL,d0
  555.         rts
  556.  
  557.  
  558. *------ Reply Workbench message
  559. repWbMsg
  560.         CALLSYS Forbid
  561.         movea.l a2,a1
  562.         CALLSYS ReplyMsg
  563.         rts
  564.  
  565.  
  566. *------ Exit
  567. _exit   move.l  4(a7),d2        ; exit(n) return code to d2
  568. exit2   movea.l _SysBase,a6     ; exit cod ein d2
  569.         suba.l  a1,a1           ; restore initial stack ptr
  570.         CALLSYS FindTask
  571.         movea.l d0,a4
  572.         movea.l pr_ReturnAddr(a4),a5
  573.         subq.l  #8,a5
  574.         subq.l  #4,a5
  575.         movea.l a5,a7
  576.         movea.l (a7)+,a2        ; recover WBenchMsg
  577.         movea.l (a7)+,a5        ; recover sVar
  578.  
  579.         IFGT    WBOUT
  580.         move.l  sv_WbOutput(a5),d1      ; Close any WbOutput file
  581.         beq.s   noWbOut
  582.         movea.l _DOSBase,a6
  583.         CALLSYS Close
  584. noWbOut movea.l _SysBase,a6     ; restore a6=ExecBase
  585.         ENDC
  586.  
  587.         movea.l _DOSBase,a1     ; close DOS library
  588.         CALLSYS CloseLibrary
  589. checkWB move.l  a2,d0           ; if we ran from CLI, skip workbench reply
  590.         beq.s   deallocSV
  591.         bsr.s   repWbMsg
  592. deallocSV
  593.  
  594.         IFEQ    QARG
  595.         movea.l a5,a1           ; deallocate the sVar structure
  596.         move.l  #sv_SIZEOF,d0
  597.         CALLSYS FreeMem
  598.         ENDC
  599.  
  600.         move.l  d2,d0           ; this rts sends us back to DOS
  601.         rts
  602.  
  603.  
  604. ********************************************************************************
  605.  
  606.         section AsmStartup,DATA
  607.  
  608. *------ Datafield
  609. DOSName DOSNAME
  610. NilName dc.b    'NIL:',0
  611.         ds.w    0
  612.  
  613.         IFGT    QARG
  614. nullArgV        dc.l    nullArg
  615. nullArg         dc.l    0       ; "" & the null entry after nullArgV
  616.         ENDC
  617.  
  618.         IFGT    WINDOW
  619. _NeedWstartup
  620.         ENDC
  621.  
  622. _SysBase        dc.l    0
  623. _DOSBase        dc.l    0
  624.  
  625.         IFGT    ASTART
  626. _WBenchMsg      dc.l    0
  627. _stdin          dc.l    0
  628. _stdout         dc.l    0
  629. _stderr         dc.l    0
  630.         ENDC
  631.  
  632.         IFGT    DEBUG
  633. initialSP       dc.l    0
  634. dosCmdLen       dc.l    0
  635. dosCmdBuf       dc.l    0
  636.         ENDC
  637.  
  638.         ENDC
  639.